@extends('admin.common.base-master')

@section('html-head')
    <link href="{{url('css/admin/pagenum.css')}}" rel="stylesheet" />

    <link rel="stylesheet" href="{{url('css/admin/jquery-ui.css')}}">
    <script type="text/javascript" src="{{url('css/admin/jquery-ui.min.js')}}"></script>
    <link href="{{url('js/lib/jquery-ui-timepicker-addon.css')}}" type="text/css" />
    <script src="{{url('js/lib/jquery-ui-timepicker-addon.js')}}" type="text/javascript"></script>
    <script src="{{url('js/lib/jquery.ui.datepicker-zh-CN.js')}}" type="text/javascript"></script>
    <script src="{{url('js/lib/jquery-ui-timepicker-zh-CN.js')}}" type="text/javascript"></script>
    <style>
        .sx{padding: 10px}
        .sx-btn{width: 64px;height: 30px;background-color: #4dbcd3;color: #fff;border: #4dbcd3;border-radius: 7%;}
    </style>
@endsection

@section('html-body')
    <!-- content start -->
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="#">活动管理</a>
            <em></em>
            <a href="#">用户发起的砍价</a>
        </div>

        @include('admin.common.activity-header')
        <!-- cur-position end -->

        <div class="filter-box clearfix">
            <div class="fl" style="display: inline-flex">
                <div class="sx">
                    <span>用户昵称：</span>
                    <input type="text" class="gg-ipt" style="width: 130px;height: 26px" placeholder="用户昵称" name="nickname" id="nickname" value="{{$nickname}}">
                </div>
                <div class="sx">
                    <span>时间：</span>
                    <input class="gg-ipt" style="width: 130px;height: 26px" type="text" placeholder="开始时间" name="start_time" id="start_time" value="{{$startTime}}" />-
                    <input class="gg-ipt" style="width: 130px;height: 26px" type="text" placeholder="结束时间" name="end_time" id="end_time" value="{{$endTime}}" />
                </div>
                <div class="sx">
                    <button class="sx-btn" id="sx_btn">筛选</button>
                </div>
            </div>
        </div>


        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>用户昵称</th>
                    <th>用户头像</th>
                    <th>商品名称</th>
                    <th>商品图片</th>
                    <th>活动结束时间</th>
                    <th>最终金额</th>
                    <th>砍价次数</th>
                    <th>活动状态</th>
                    <th>助力人数</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @if(count($activityBargainInitiates) > 0)
                    @foreach($activityBargainInitiates as $a)
                        <tr id="admin_{{$a->id}}">
                            <td>{{$a->id}}</td>
                            <td>{{$a->nickname}}</td>
                            <td><img src="{{$a->photo_url}}" alt="" width="40px"></td>
                            <td>{{$a->goods_name}}</td>
                            <td><img src="{{$a->thumb_url}}" alt="" width="40px"></td>
                            <td>{{$a->end_time}}</td>
                            <td>{{$a->finally_money}}</td>
                            <td>{{$a->bargain_num}}</td>
                            <td>
                                @if($a->status == -1)
                                    <p style="color: red;">取消</p>
                                @elseif($a->status == 0)
                                    <p style="color: #008200;">正常</p>
                                @elseif($a->status == 1)
                                    <p style="color: green;">完成</p>
                                @endif

                            </td>
                            <td>
                                <a class="color2" href="{{route('Admin.Home.userBargainJoinList')}}?id={{$a->id}}">查看</a>
                            </td>
                            <td>
                                <a class="color2" href="{{route('Admin.Home.userBargainInitiateDetail')}}?id={{$a->id}}">查看详情</a>
                            </td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
            </table>
            <?php echo $activityBargainInitiates->appends(['nickname' => $nickname,'start_time' => $startTime,'end_time' => $endTime])->render(); ?>
        </div>
    </div>
    <!-- content end -->
    <script>

        $(function(){
            jQuery('#start_time').datetimepicker({
                timeFormat: "HH:mm:ss",
                dateFormat: "yy-mm-dd",
                beforeShow: function () {
                    setTimeout(
                            function () {
                                $('#ui-datepicker-div').css("z-index", 1000);
                            }, 100
                    );
                }
            });

            jQuery('#end_time').datetimepicker({
                timeFormat: "HH:mm:ss",
                dateFormat: "yy-mm-dd",
                beforeShow: function () {
                    setTimeout(
                            function () {
                                $('#ui-datepicker-div').css("z-index", 1000);
                            }, 100
                    );
                }
            });

            $('#sx_btn').click(function(){
                var nickname  = $('#nickname').val();
                var startTime = $('#start_time').val();
                var endTime   = $('#end_time').val();

                window.location.href = "{{route('Admin.Home.userBargainInitiateList')}}?nickname="+nickname+"&start_time="+startTime+"&end_time="+endTime;
            });

        });
    </script>

@endsection